using System;
using System.Collections.Generic;

namespace Karma.Framework.Core.Modules.Reports.Definition.Expression
{
    internal class NotExpression : UnaryExpression
    {
        public NotExpression(Criteria criteria)
            : base(criteria)
        {
        }

        public override CompiledExpression Compile(Report report)
        {
            var exp = new CompiledExpression
            {
                Parameters = new Dictionary<string, object>()
            };
            var parameter = GenerateIdentifier();
            exp.Expression = string.Format("{0}.{1} not :{2}", GetIdentifier(report), _operand, parameter);

            exp.Parameters.Add(parameter, Cast(_criteria.OperandValues[0]));
            return exp;
        }

    }
}